<template>

  <mt-popup
    v-model="isShow"
    size="large"
    class="mint-popup-4"
    position="bottom">

    <div>
      <div class="fx-row fx-row-space-between mint-pick-popup-util">
        <a @click="hide" href="javascript:void(0)" class="text-color-light">取消</a>
        <a @click="complete" href="javascript:void(0)" class="text-primary">完成</a>
      </div>
        <mt-picker  v-if="isShow"  ref="picker" :show-toolbar="false"   :slots="slots" @change="onValuesChange"></mt-picker>
    </div>

  </mt-popup>



</template>
<style lang="scss" scoped>
  .mint-popup-4{
    width: 100%;
  }
  .mint-pick-popup-util{
    &>a{
      padding: 15px;
      padding-bottom: 5px;
      font-size: 14px;
    }
  }
</style>
<script>
  import Util from "util";
  import { Popup,Picker} from 'mint-ui';

    export default{

      props : {

      },

      data(){
          return{
              slots: [],
              isShow : false,
              type : ''
          }
        },
     methods : {

        onValuesChange : function(picker, values){
           //if (values[0] > values[1]) {
             // picker.setSlotValue(1, values[0]);
          //}
        },
        complete  : function(){
            this.$emit("pickpoppupComplete",this.type,this.$refs.picker.getValues());
            this.isShow = false;
        },

        hide : function(){
          this.isShow = false;
        },

        show   : function(type,list,valueKey,index){
          if(type == "") throw new Error("传递type");

         var slots = [];
         let ib = list.length;
         for(var i=0;i<list.length;i++){
            let  dataArray = list[i];
            slots.push({
                flex: 1,
                values: dataArray,
                className: 'slot'+(i+1)
              })
         }

          this.slots = slots;
          this.type = type;
          this.isShow = true;

          //if(index)
            //this.$refs.picker.setSlotValues(index,list[index]);
        },



        getSelectedVal : function(){
          return this.$refs.picker.getValues()[0];
        }

     },
        components:{

        }
    }
</script>
